package com.moduls.interfaceFunction.core;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@ControllerAdvice
public class GlobalExceptionHandler {
    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public Result errorHandler(Exception e) {
        Result r = new Result();
        r.setMessage(e.getMessage());
        r.setStatus(500);
        return r;
    }

    @ResponseBody
    @ExceptionHandler(value = MyException.class)
    public Result myErrorHandler(MyException e) {
        Result r = new Result();
        r.setMessage(e.getMessage());
        r.setStatus(e.getStatus());
        return r;
    }
}
